package com.bungarus.model;

import java.io.Serializable;

/**
 * Created by tang on 2018/11/12.
 */
public class Session implements Serializable {
    public static final String TAG = "transfer";
    //session id
    private String id;
    //user id not account name
    private String userId;
    //tenant id
    private String tenantId;
    //device which sent message
    private String dev;
    //app which sent message
    private String app;
    //ip the client accessed
    private String ip;
    //port the client used to access
    private int port;
    //random key to be used to encrypt message
    private String key;
    //timestamp the session created at
    private long created;
    //token
    private String token;

    public static final SessionBuilder newBuilder(){
        return new Session().toBuilder();
    }

    private SessionBuilder toBuilder() {
        return new SessionBuilder(this);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Session)) return false;

        Session session = (Session) o;

        return !(getId() != null ? !getId().equals(session.getId()) : session.getId() != null);

    }

    @Override
    public int hashCode() {
        return getId() != null ? getId().hashCode() : 0;
    }

    @Override
    public String toString() {
        return "Session{" +
                "id='" + id + '\'' +
                ", userId='" + userId + '\'' +
                ", tenantId='" + tenantId + '\'' +
                ", dev='" + dev + '\'' +
                ", app='" + app + '\'' +
                ", ip='" + ip + '\'' +
                ", port=" + port +
                ", key='" + key + '\'' +
                ", created=" + created +
                ", token='" + token + '\'' +
                '}';
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getTenantId() {
        return tenantId;
    }

    public void setTenantId(String tenantId) {
        this.tenantId = tenantId;
    }

    public String getDev() {
        return dev;
    }

    public void setDev(String dev) {
        this.dev = dev;
    }

    public String getApp() {
        return app;
    }

    public void setApp(String app) {
        this.app = app;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public long getCreated() {
        return created;
    }

    public void setCreated(long created) {
        this.created = created;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }
}
